import { store } from '../stores/home'
import { genSetNotify } from "../actions/home"

const onSetNotify = (type, message) => {
    store.dispatch(genSetNotify(type, message))
}

export const notify = (type, message) => {
    const messageOfArray = Array.isArray(message) ? message : [message],
        joinedMessage = messageOfArray.join('<br/>')

    onSetNotify(type, joinedMessage)
    if (type && joinedMessage) {
        setTimeout(() => {
            onSetNotify('', '')
        }, 5000)
    }
}